package com.jason.game.online.home.adapter

import android.content.Context
import android.view.View
import com.cby.library.data.model.GameInfoBean
import com.cby.library.widget.adapter.SimpleBaseAdapter
import com.jason.game.online.R
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import com.cby.library.common.ext.load

/**
 * 描述信息
 *
 * @author 徐智伟
 * @create 2018/11/28
 */
class GameGridItem2Adapter(
    context: Context?,
    data: List<GameInfoBean?>?
) : SimpleBaseAdapter<GameInfoBean?>(context, data) {
    override fun getItemResource(): Int {
        return R.layout.item_home_grid_2
    }

    override fun getItemView(
        position: Int, convertView: View, parent: ViewGroup,
        holder: ViewHolder
    ): View {
        val nameTextView: TextView = holder.findView<TextView>(R.id.tv_game_item_name)
        val categoryTextView: TextView = holder.findView<TextView>(R.id.tv_game_item_category)
        val iconImageView: ImageView = holder.findView<ImageView>(R.id.iv_game_item_icon)
        data[position]?.let {
            nameTextView.text = it.title
            categoryTextView.text = it.className
            iconImageView.load(it.icon, R.drawable.loading_bixue)
        }

        return convertView
    }
}